home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 4701 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  2.2 KB

  1. Path: sdrc.com!thor!scjones
  2. From: larry.jones@sdrc.com (Larry Jones)
  3. Newsgroups: comp.lang.c,comp.lang.c++,gnu.gcc.help,gnu.g++.help,comp.os.msdos.djgpp
  4. Subject: Re: float != float and floats as return types
  5. Date: 31 Jan 1996 18:25:23 GMT
  6. Organization: SDRC Engineering Services
  7. Distribution: world
  8. Message-ID: <4eoc6j$8vi@info1.sdrc.com>
  9. References: <4ej9lb$mpc@fu-berlin.de> <310D4D9C.7DAB2E1B@alcyone.com> <310DF403.2EDA7BBD@alcyone.com>
  10. NNTP-Posting-Host: thor.sdrc.com
  11. Originator: scjones@thor
  12.  
  13. In article <310DF403.2EDA7BBD@alcyone.com>, Erik Max Francis <max@alcyone.com> writes:
  14. > Russell Blackadar wrote:
  15. > > What is surprising is that all the columns are not zero!  The original poster
  16. > > was offering some speculations as to how that might have happened, but as you
  17. > > say (and I think he'd agree) it doesn't wash.  I ran his posted code and
  18. > > got all zeroes.  Either there's a *serious* problem with his compiler, or the
  19. > > posted code is not the same as what he compiled.
  20. > Not at all.  Systematic errors are expected when using floating point
  21. > computations.
  22. > Under gcc 2.6.3 for Linux, his program prints the following:
  23.  
  24. Making gcc an ANSI/ISO Standard conforming compiler is trickier than it
  25. seems -- the required options are neither simple nor obvious.  This is
  26. particularly true in places like floating point arithmetic where people
  27. are generally less concerned with getting the exactly ``correct''
  28. results (i.e., what the standard says you should get) than they are
  29. with getting reasonably correct results fast.
  30.  
  31. In particular, the standard generally allows a compiler to compute
  32. floating point results with more precision than it requires, but there
  33. are a number of places where it requires any excess precision to be
  34. removed.  gcc generally does not remove the excess precision in those
  35. cases.  Specifying -ffloat-store helps; on i386/i486 machines so does
  36. -mno-fp-ret-in-387; but, as far as I can tell, there is no way (as of
  37. gcc 2.7.1) to make gcc conform completely on i386/i486 machines as there
  38. is no way to force it to remove precision as a result of a cast.
  39. ----
  40. Larry Jones, SDRC, 2000 Eastman Dr., Milford, OH  45150-2789  513-576-2070
  41. larry.jones@sdrc.com
  42. I like maxims that don't encourage behavior modification. -- Calvin
  43.